package com.runen.infinitemovement.tool;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

import com.runen.infinitemovement.R;


/**
 * Author: SXF
 * E-mail: xue.com.fei@outlook.com
 * CreatedTime: 2016/2/20 11:06
 * <p>
 * ActivityAnimationUtil
 */

public class ActivityAnimationUtil {

    private ActivityAnimationUtil() {
        throw new UnsupportedOperationException(
                "ActivityAnimationUtil cannot be instantiated");
    }

    public static void startActivity(Context context, Intent intent) {
        if (NoDoubleClickUtils.isDoubleClick()) {
            return;
        }
        ((Activity) context).startActivity(intent);
        ((Activity) context).overridePendingTransition(R.anim.activity_start_in, R.anim.activity_start_out);
    }

    public static void startActivityForFinish(Context context, Intent intent) {
        if (NoDoubleClickUtils.isDoubleClick()) {
            return;
        }
        ((Activity) context).startActivity(intent);
        ((Activity) context).overridePendingTransition(R.anim.activity_start_in, R.anim.activity_start_out);
        ((Activity) context).finish();
    }

    public static void startActivityForResult(Context context, Intent intent, int requestCode) {
        if (NoDoubleClickUtils.isDoubleClick()) {
            return;
        }
        ((Activity) context).startActivityForResult(intent, requestCode);
        ((Activity) context).overridePendingTransition(R.anim.activity_start_in, R.anim.activity_start_out);
    }

    public static void finishActivity(Context context) {
        ((Activity) context).finish();
        ((Activity) context).overridePendingTransition(R.anim.activity_finish_in, R.anim.activity_finish_out);
    }

    public static void finishActivityForResult(Context context, Intent intent, int resultCode) {
        if (NoDoubleClickUtils.isDoubleClick()) {
            return;
        }
        ((Activity) context).setResult(resultCode, intent);
        ((Activity) context).finish();
        ((Activity) context).overridePendingTransition(R.anim.activity_finish_in, R.anim.activity_finish_out);
    }


}
